package com.yc.common.handler;

import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 朱盼林
 * @version 1.0
 * @description:
 * @date 2023/7/6 21:23
 */
@SuppressWarnings("all")
public class MapResultHandler<K, V> implements ResultHandler {

    private Map<K, V> mappedResults = new HashMap<>();

    @Override
    public void handleResult(ResultContext resultContext) {
        Map map = (Map) resultContext.getResultObject();
        mappedResults.put((K)map.get("key"), (V)map.get("value"));
    }

    public Map<K, V> getMappedResults() {
        return mappedResults;
    }
}
